/**
 * @Question demo2
 * @Date 2022/10/16 22:59
 * @Solution
 */
interface Shape2D {
    public double area();
    public double perimeter();
}
abstract class Geometry {
    public abstract double getArea();
}
class Circle extends Geometry implements Shape2D{
    int r;
    public Circle(int r) {
        this.r=r;
    }
    @Override
    public double getArea() {
        return Math.PI*(r*r);
    }

    @Override
    public double area() {
        return Math.PI*(r*r);
    }

    @Override
    public double perimeter() {
        return Math.PI*2*r;
    }
}
class Rect extends Geometry implements Shape2D{
    int x;
    int y;
    public Rect(int x,int y) {
        this.x=x;
        this.y=y;
    }
    @Override
    public double getArea() {
        return (double) x*y;
    }

    @Override
    public double area() {
        return (double) x*y;
    }

    @Override
    public double perimeter() {
        return (double) (2*(x+y));
    }
}
public class demo2 {
    public static void main(String[] args) {
        Rect rect = new Rect(3,5);
        Circle circle = new Circle(5);
        System.out.println("半径为5的圆的面积与周长分别为："+circle.area()+","+circle.perimeter());
        System.out.println("高为5宽为3的矩形面积与周长分别为："+rect.area()+","+rect.perimeter());
    }
}
